package com.spzx.order.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.order.api.RemoteOrderInfoService;
import com.spzx.order.api.domain.OrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RemoteOrderInfoFallbackFactory implements FallbackFactory<RemoteOrderInfoService> {
//    private static final Logger log = LoggerFactory.getLogger(RemoteOrderInfoFallbackFactory.class);
    @Override
    public RemoteOrderInfoService create(Throwable cause) {
        log.error("支付调用失败：{}",cause.getMessage());
        return new RemoteOrderInfoService() {
            @Override
            public R<OrderInfo> getByOrderNo(String orderNo, String source) {
                System.out.println("发生异常，调用降级方法： getByOrderNo");
                return null;
            }
        };
    }
}
